package com.ganinfo.sys.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ganinfo.common.Result;
import com.ganinfo.common.controller.BaseController;
import com.ganinfo.common.data.ParmaterUtils;
import com.ganinfo.common.data.TransmitMap;
import com.ganinfo.sys.model.SysRolePermission;
import com.ganinfo.sys.service.ISysRolePermissionService;

/**
 * @ClassName:   SysRolePermissionController
 * @Description: [sys_role_permission]控制类
 * @author:      ruikanwang
 * @date:        
 */
@Controller
public class SysRolePermissionController extends BaseController {

    private final ISysRolePermissionService service;

    @Autowired
    public SysRolePermissionController(ISysRolePermissionService service) {
        this.service = service;
    }

    /**
     * @Title:       getSysRolePermissionList
     * @Description: 分页获取列表
     * @param：                    pageSize(每页记录数) pageNumber(页数) orderby(排序字段) orderbymethod(排序方式)
     * @return
     * @return:      String
     */
    @RequestMapping(value="/getSysRolePermissionList",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})
    @ResponseBody
    public Result getSysRolePermissionList(SysRolePermission paramSysRolePermission) {
    	Result returndate=null;
    	TransmitMap transmitMap = this.getTransmitMap();
    	List<String> paramCheckList = ParmaterUtils.paramCheck(transmitMap,"pageSize","pageNumber");
    	if(paramCheckList.size() > 0){
    		returndate=this.renderParamError(paramCheckList);
		}else{
			try {
				returndate=this.renderSuccess(service.getSysRolePermissionList(transmitMap));
			} catch (Exception e) {
				returndate=this.renderError();
				e.printStackTrace();
			}
		}
        return returndate;
    }
    
    /**
     * @Title:       addSysRolePermission
     * @Description: 添加
     * @param 
     * @return
     * @return:      String
     */
    @RequestMapping(value="/addSysRolePermission",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})
    @ResponseBody
    public Result addSysRolePermission(SysRolePermission paramSysRolePermission) {
    	Result returndate=null;
    	try {
    		if(service.addSysRolePermission(paramSysRolePermission)){
    			returndate=this.renderSuccess(null);
    		}else{
    			returndate=this.renderError();
    		}
		} catch (Exception e) {
			returndate=this.renderError();
			e.printStackTrace();
		}
        return returndate;
    }
    
    /**
     * @Title:       updateSysRolePermission
     * @Description: 更新
     * @param        paramSysRolePermission
     * @return
     * @return:      String
     */
    @RequestMapping(value="/updateSysRolePermission",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})
    @ResponseBody
    public Result updateSysRolePermission(SysRolePermission paramSysRolePermission) {
    	Result returndate=null;
    	try {
    		if(service.updateSysRolePermission(paramSysRolePermission)){
    			returndate=this.renderSuccess(null);
    		}else{
    			returndate=this.renderError();
    		}
		} catch (Exception e) {
			returndate=this.renderError();
			e.printStackTrace();
		}
        return returndate;
    }
    
    /**
     * @Title:       deleteSysRolePermission
     * @Description: 删除
     * @param paramSysRolePermission
     * @return
     * @return:      String
     */
    @RequestMapping(value="/deleteSysRolePermission",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})
    @ResponseBody
    public Result deleteSysRolePermission(SysRolePermission paramSysRolePermission) {
    	Result returndate=null;
    	try {
    		if(service.deleteSysRolePermission(paramSysRolePermission)){
    			returndate=this.renderSuccess(null);
    		}else{
    			returndate=this.renderError();
    		}
		} catch (Exception e) {
			returndate=this.renderError();
			e.printStackTrace();
		}
        return returndate;
    }
}
